// GET /projects/{project-id}/objects/{class}/{subclass}/{type}/icon/raw
func (resource *WorkspaceResource) getObjectIconAsRaw(request *restful.Request, response *restful.Response) {
	projectID := request.PathParameter("project-id")
	project, err := resource.ws.Project(projectID)

	if err == nil {
		classID, _ := strconv.ParseInt(request.PathParameter("class"), 10, 8)
		subclassID, _ := strconv.ParseInt(request.PathParameter("subclass"), 10, 8)
		typeID, _ := strconv.ParseInt(request.PathParameter("type"), 10, 8)
		objID := res.MakeObjectID(res.ObjectClass(classID), res.ObjectSubclass(subclassID), res.ObjectType(typeID))
		bmp := project.GameObjects().Icon(objID)
		var entity model.RawBitmap

		entity.Width = int(bmp.ImageWidth())
		entity.Height = int(bmp.ImageHeight())
		var pixel []byte

		for row := 0; row < entity.Height; row++ {
			pixel = append(pixel, bmp.Row(row)...)
		}
		entity.Pixels = base64.StdEncoding.EncodeToString(pixel)

		response.WriteEntity(entity)
	} else {
		response.AddHeader("Content-Type", "text/plain")
		response.WriteErrorString(http.StatusBadRequest, err.Error())
		return
	}
}
// GET /projects/{project-id}/textures/{texture-id}/{texture-size}/raw
func (resource *WorkspaceResource) getTextureImageAsRaw(request *restful.Request, response *restful.Response) {
	projectID := request.PathParameter("project-id")
	project, err := resource.ws.Project(projectID)

	if err == nil {
		textureID, _ := strconv.ParseInt(request.PathParameter("texture-id"), 10, 16)
		textureSize := request.PathParameter("texture-size")
		bmp := project.Textures().Image(int(textureID), model.TextureSize(textureSize))
		var entity model.RawBitmap

		entity.Width = int(bmp.ImageWidth())
		entity.Height = int(bmp.ImageHeight())
		var pixel []byte

		for row := 0; row < entity.Height; row++ {
			pixel = append(pixel, bmp.Row(row)...)
		}
		entity.Pixels = base64.StdEncoding.EncodeToString(pixel)

		response.WriteEntity(entity)
	} else {
		response.AddHeader("Content-Type", "text/plain")
		response.WriteErrorString(http.StatusBadRequest, err.Error())
		return
	}
}