AutoHotkey Community

It is currently May 27th, 2012, 1:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20, 21, 22 ... 67  Next
Author Message
 Post subject:
PostPosted: November 19th, 2009, 5:54 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 6:16 pm 
Hi, below I am trying to use the myColMat to adjust a bitmap. However, the results are poor, and not approximate. Gradient shades turn murky colours. Does anyone know how to remedy/fix this? :D

Code:
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, myColMat)

... re-drawn pBitmap looks ugly with this method




mrr19121970 wrote:
see here http://msdn.microsoft.com/en-us/library ... nd%29.aspx

using your image as input try:

Code:
;red
;myColMat = ("0|0|0|-1|1|1|-1|-1|0|0|1|-1|-1|0|0|1|-1|-1|0|0|1|-1|-1|0|0|")
;green
myColMat = ("0|0|0|-1|1|-1|1|-1|0|0|-1|1|-1|0|0|-1|1|-1|0|0|-1|1|-1|0|0")
;blue
;myColMat = ("0|0|0|-1|1|-1|-1|1|0|0|-1|-1|1|0|0|-1|-1|1|0|0|-1|-1|1|0|0")
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, myColMat)



or add (after line 33):

Code:
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vRED Range-100-100, 0
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vGREEN Range-100-100, 0
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vBLUE Range-100-100, 0


and (before line 124):

Code:
RED := RED/100
GREEN := GREEN/100
BLUE := BLUE/100
myColMat = ("0|0|0|-1|1|%RED%|%GREEN%|%BLUE%|0|0|%RED%|%GREEN%|%BLUE%|0|0|%RED%|%GREEN%|%BLUE%|0|0|%RED%|%GREEN%|%BLUE%|0|0")


replacing line 124 with

Code:
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, myColMat)


to example 10 to play yourself.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 10:56 am 
Offline

Joined: May 22nd, 2009, 2:48 pm
Posts: 12
mrr19121970 wrote:
Image

It looks nice, indeed.
Maybe the font sizes below 24 point with background image and color made my tests look ugly.
thank you. I find your subtitle script very interesting.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 1:24 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
Image

The improved code is here. This is arial 24 with 1pt border.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: raw pixel data and gdip
PostPosted: November 27th, 2009, 9:42 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
tic wrote:
You'll see that I already had those functions, but for a different purpose in Gdip_BitmapFromBRA() which I have as of yet not told anyone how to use :P

Hi Tic. Would you give an example on how to use Gdip_BitmapFromBRA() ?
Also, is the inverse possible ? : Gdip_BRAFromBitmap()

What I am interested in doing is mixing calls to DrawImage with numput.
if i create a dibsection and get a pointer to the pixeldata (ppvbits), can i use drawimage and numput, to get and set the pixeldata from ppvbits directly?

I am able to change the data in ppvbits using c in my medical image viewing program: ahkpacs. I am interested in using gdi+ drawimage functions on the same dibsections / ppvbit data also.

I am willing to use 24bit images (currently using 8bit images, but you have told me previously that drawimage doesn't work with 8 bit images).

Thanks.

[Edit]
I think I figured it out. Looks like sean's screencapture.ahk actually captures images to a dibsection before writing to a file... essentially a Gdip_BRAFromBitmap()...
Also, it seems I can just pass the bitmap created with createdibsection to Gdip_GraphicsFromImage(pBitmap)...

Now, I wonder if I can mix gdip with opengl as opengl seems to have much better support for 16bit grayscale images, and will probably enable other performance gains with double buffering and 3d textures...

do you have a double buffering example with gdip?


Last edited by tinku99 on December 27th, 2009, 6:44 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2009, 9:35 pm 
Hello, thank you if anyone can tell me what I didn't do to make this work. Several Windows based paint programs allow this sort of function. I don't see precisely all the way the function works to the degree I am asking below. Thank you all for any kind & helpful assistance! :)

Halp-Life wrote:
Hi, below I am trying to use the myColMat to adjust a bitmap. However, the results are poor, and not approximate. Gradient shades turn murky colours. Does anyone know how to remedy/fix this? :D

Code:
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, myColMat)

... re-drawn pBitmap looks ugly with this method




mrr19121970 wrote:
see here http://msdn.microsoft.com/en-us/library ... nd%29.aspx

using your image as input try:

Code:
;red
;myColMat = ("0|0|0|-1|1|1|-1|-1|0|0|1|-1|-1|0|0|1|-1|-1|0|0|1|-1|-1|0|0|")
;green
myColMat = ("0|0|0|-1|1|-1|1|-1|0|0|-1|1|-1|0|0|-1|1|-1|0|0|-1|1|-1|0|0")
;blue
;myColMat = ("0|0|0|-1|1|-1|-1|1|0|0|-1|-1|1|0|0|-1|-1|1|0|0|-1|-1|1|0|0")
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, myColMat)



or add (after line 33):

Code:
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vRED Range-100-100, 0
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vGREEN Range-100-100, 0
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vBLUE Range-100-100, 0


and (before line 124):

Code:
RED := RED/100
GREEN := GREEN/100
BLUE := BLUE/100
myColMat = ("0|0|0|-1|1|%RED%|%GREEN%|%BLUE%|0|0|%RED%|%GREEN%|%BLUE%|0|0|%RED%|%GREEN%|%BLUE%|0|0|%RED%|%GREEN%|%BLUE%|0|0")


replacing line 124 with

Code:
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, myColMat)


to example 10 to play yourself.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2009, 4:15 am 
hi i am looking for solution to GDIP problem having above, with the sequence to make a graident image work out right. can i show example or ne1 know what is wrong? :{


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2009, 3:08 am 
Hi, I just had a quick question I'm hoping one of the GDI+ gurus can answer. I cant figure out how to rotate an image and save it to file. The example #10 works fine for me, but when I try to write the file to the disk, it just creates an unrotated copy of the file. I assume I'm somehow not applying the graphics to the bitmap, but I cant figure out how. Anyone have an idea?

Thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2009, 8:39 am 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
You're calling Gdip_SaveBitmapToFile(pBitmap,Output) with the wrong pointer. Post your code so we can help further.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2009, 3:17 am 
Offline

Joined: December 12th, 2009, 3:13 am
Posts: 15
This is the relevant part of the code, its taken from tutorial #10, and I added the savebitmaptofile commands (all 4 since I thought maybe I was putting the first one in the wrong place)


Code:
If Horizontal
Gdip_ScaleWorldTransform(G, -1, 1), Gdip_TranslateWorldTransform(G, -Width, 0)
If Vertical
Gdip_ScaleWorldTransform(G, 1, -1), Gdip_TranslateWorldTransform(G, 0, -Height)

Gdip_SaveBitmapToFile(pBitmap, "out.jpg")

Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight)

Gdip_SaveBitmapToFile(pBitmap, "out2.jpg")

Gdip_ResetWorldTransform(G)

Gdip_SaveBitmapToFile(pBitmap, "out3.jpg")

UpdateLayeredWindow(hwnd2, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)

Gdip_SaveBitmapToFile(pBitmap, "out4.jpg")

SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap)


thx for helping :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2009, 3:18 am 
Offline

Joined: December 12th, 2009, 3:13 am
Posts: 15
Oh, I've tried using G instead of pBitmap, and no file gets created


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2009, 1:34 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
tinku99:

I will attempt to show how to use bra functions over the next week. I will bring out a new example

Halp-Life:

The colour matrix example that mrr19121970 gave seems to work perfectly

aparden:

The problem you have is that you are trying to save the original pBitmap to disk again. That pBitmap is being drawn onto the Graphics of a gdi bitmap, which is not what you want. you have 3 solutions depending on what you are going to be using this for. I will list the 2 best solutions. If you still want a gui then I would do the same as the example, but then also make a new pBitmap and get the graphics context of that and then do everything the same as that example...so do:

Code:
pBitmap := Gdip_CreateBitmap(Width, Height)
G := Gdip_GraphicsFromImage(pBitmap)


where Width and Height are the dimensions of the image from disk. Then use this G instead of (or as well as) the other G from then on. The alternative is to get a gdi+ bitmap from the resulting gdi bitmap at the end, however, you will have no alpha channel in this bitmap


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2009, 9:43 pm 
Offline

Joined: December 12th, 2009, 3:13 am
Posts: 15
tic, you're the man, thx!

I figured it was something about not applying the transformed graphics to the bitmap, thx for pointing out the specifics :)

Could I get you to briefly scan this code, just to verify that its not going to be leaving anything open in memory or anything that is unneeded? I havnt added error checking or anything, I just wanna know if I'm cleaning up correctly ;)

Code:
File1 = file.jpg
Angle = 45

; Start gdi+
If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}


pBitmap := Gdip_CreateBitmap(350, 350)
G := Gdip_GraphicsFromImage(pBitmap)

pBitmapFile1 := Gdip_CreateBitmapFromFile(File1)
Width := Gdip_GetImageWidth(pBitmapFile1), Height := Gdip_GetImageHeight(pBitmapFile1)

; using white in my program, green for testing
;pBrush := Gdip_BrushCreateSolid(0xffffffff)
pBrush := Gdip_BrushCreateSolid(0xff00ff00)
Gdip_FillRectangle(G, pBrush, 0, 0, 350, 350)
Gdip_DeleteBrush(pBrush)

Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight)
Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation)
Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
Gdip_RotateWorldTransform(G, Angle)


Gdip_DrawImage(G, pBitmapFile1, 0, 0, Width, Height, 0, 0, Width, Height)

Gdip_DisposeImage(pBitmapFile1)
Gdip_SaveBitmapToFile(pBitmap, "out.jpg")

Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 1:29 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Yep, you disposed of everything correctly. The only thing to note is that you didnt use RWidth and RHeight from Gdip_GetRotatedDimensions to create your new bitmap at the correct dimensions once its been rotated. Your code, but rejiggled to the correct order is below:

Code:
File1 = file.jpg
Angle = 45

; Start gdi+
If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}

pBitmapFile1 := Gdip_CreateBitmapFromFile(File1)
Width := Gdip_GetImageWidth(pBitmapFile1), Height := Gdip_GetImageHeight(pBitmapFile1)

Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight)
Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation)

pBitmap := Gdip_CreateBitmap(RWidth, RHeight)
G := Gdip_GraphicsFromImage(pBitmap)

; using white in my program, green for testing
;pBrush := Gdip_BrushCreateSolid(0xffffffff)
pBrush := Gdip_BrushCreateSolid(0xff00ff00)
Gdip_FillRectangle(G, pBrush, 0, 0, RWidth, RHeight)
Gdip_DeleteBrush(pBrush)

Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
Gdip_RotateWorldTransform(G, Angle)

Gdip_DrawImage(G, pBitmapFile1, 0, 0, Width, Height, 0, 0, Width, Height)

Gdip_DisposeImage(pBitmapFile1)
Gdip_SaveBitmapToFile(pBitmap, "out.jpg")

Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)


If you ever find yourself unsure of whether youve disposed of everything then you can loop your code and use the process tab in task manager to see if the memory usage increases over time.
I advise you dont use setbatchlines -1 when testing, and always have a hotkey to close your program

hope this helps....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 5:36 am 
Offline

Joined: December 12th, 2009, 3:13 am
Posts: 15
sweet thx :D

And I figured out the RWidth and RHeight thing right after I posted. Whats the reason for the code reorganization? So that the calculations are done prior to the bitmap being loaded in memory?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20, 21, 22 ... 67  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], Google Feedfetcher and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group